GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
cairo_region_t *input_shape;
- child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
- child->xid, ShapeBounding);
+ child->shape = NULL;
+ if (gdk_display_supports_shapes (display))
+ child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
+ child->xid, ShapeBounding);
#ifdef ShapeInput
- input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
- child->xid, ShapeInput);
+ input_shape = NULL;
+ if (gdk_display_supports_input_shapes (display))
+ input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
+ child->xid, ShapeInput);
+
if (child->shape && input_shape)
{
cairo_region_intersect (child->shape, input_shape);
shape = NULL;
rn = 0;
- xrl = XShapeGetRectangles (xdisplay,
- window,
- shape_type, &rn, &ord);
+ /* Note that XShapeGetRectangles returns NULL in two situations:
+ * - the server doesn't support the SHAPE extension
+ * - the shape is empty
+ *
+ * Since we can't discriminate these here, we always return
+ * an empty shape. It is the callers responsibility to check
+ * whether the server supports the SHAPE extensions beforehand.
+ */
+ xrl = XShapeGetRectangles (xdisplay, window, shape_type, &rn, &ord);
- if (xrl == NULL || rn == 0)
+ if (rn == 0)
return cairo_region_create (); /* Empty */
if (ord != YXBanded)
{
/* This really shouldn't happen with any xserver, as they
- generally convert regions to YXBanded internally */
+ * generally convert regions to YXBanded internally
+ */
g_warning ("non YXBanded shape masks not supported");
XFree (xrl);
return NULL;
rl[i].height = xrl[i].height;
}
XFree (xrl);
-
+
shape = cairo_region_create_rectangles (rl, rn);
g_free (rl);
-
+
return shape;
}
{
#if defined(ShapeInput)
if (!GDK_WINDOW_DESTROYED (window) &&
- gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
+ gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
return _gdk_x11_xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
ShapeInput);